package rs.pnv.model.payment;

import java.math.BigInteger;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;

import org.apache.commons.lang3.builder.EqualsBuilder;
import org.apache.commons.lang3.builder.HashCodeBuilder;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import org.hibernate.validator.constraints.NotBlank;
import org.hibernate.validator.constraints.URL;

import rs.pnv.model.AbstractEntity;

@Entity
@Table(name = "SEP_PAYMENT_URL")
@XmlAccessorType(XmlAccessType.FIELD)
public class PaymentUrl extends AbstractEntity {

	@NotBlank
	@URL
	@Column(nullable = false)
	@XmlElement(nillable = false)
	private String url;

	@NotBlank
	@Column(nullable = false)
	@XmlElement(nillable = false)
	private BigInteger paymentUrlId;

	public PaymentUrl() {

	}

	public String getUrl() {
		return url;
	}

	public void setUrl(String url) {
		this.url = url;
	}

	public BigInteger getPaymentUrlId() {
		return paymentUrlId;
	}

	public void setPaymentUrlId(BigInteger paymentUrlId) {
		this.paymentUrlId = paymentUrlId;
	}

	@Override
	public int hashCode() {
		return new HashCodeBuilder()
				.append(url)
				.append(paymentUrlId)
				.appendSuper(super.hashCode())
				.hashCode();
	}

	@Override
	public boolean equals(Object obj) {
		if (obj == null) {
			return false;
		}
		if (obj == this) {
			return true;
		}
		if (obj.getClass() != getClass()) {
			return false;
		}

		final PaymentUrl otherPaymentUrl = (PaymentUrl) obj;

		return new EqualsBuilder()
				.append(url, otherPaymentUrl.getUrl())
				.append(paymentUrlId, otherPaymentUrl.getPaymentUrlId())
				.appendSuper(super.equals(obj))
				.isEquals();
	}

	@Override
	public String toString() {
		return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE)
				.append("url", url)
				.append("paymentUrlId", paymentUrlId)
				.append(super.toString())
				.toString();
	}
}
